package com.maikang.exammall.entity.dto.user;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.maikang.exammall.entity.User;
import com.maikang.exammall.entity.dto.promote.EarningDTO;
import com.maikang.exammall.util.validator.NotBlankOrNull;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Null;


@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class UserProfileDTO {

    private Long id;

    public UserProfileDTO(Long id, Integer gender, String mobile, String username, String avatarUrl) {
        this.id = id;
        this.gender = gender;
        this.mobile = mobile;
        this.username = username;
        this.avatarUrl = avatarUrl;
    }

    @ApiModelProperty("1- 男, 2-女")
    private Integer gender;

    @ApiModelProperty("0: 普通用户, 1：1级销售， 2： 2级销售")
    private Integer role = 0;

    @ApiModelProperty("收益")
    private EarningDTO earning;

    @Null
    private String mobile;
    @NotBlankOrNull
    private String username;

    private String avatarUrl;

    public UserProfileDTO(User user) {
        this.id = user.getId();
        this.gender = user.getGender();
        this.mobile = user.getMobile();
        this.avatarUrl = user.getAvatarUrl();
    }
}
